package top.zosoft.bootstrap;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import top.zosoft.builder.ServerBuilder;
import top.zosoft.enums.ServerType;
import top.zosoft.server.MqttBroker;
import top.zosoft.server.Server;

/**
 * @author neal
 * @date 2023/12/27  12:49
 */
@Configuration
public class MqttBootstrap {
    @Autowired
    MqttBroker mqttBroker;
    @Bean(initMethod = "start", destroyMethod = "stop")
    public Server MqttBroker(){
        ServerBuilder.Builder builder = ServerBuilder.builder()
                .setServer(mqttBroker)
                .setName(ServerType.MQTT.getName())
                .setType(ServerType.MQTT)
                .setPort(8888);
        return builder.build();
    }

}
